package com.qymerge.manage.core.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.lang.reflect.Type;

/**
 * Desc
 * User licong
 * Date 2016/6/23
 * Time 18:08
 */
public class WxGsonUtil {

    /**
     * 不对html转义
     * @return
     */
    public static Gson getGson() {
        return new GsonBuilder().disableHtmlEscaping().create();
    }

    /**
     * 对象转换成json
     * @param object
     * @return
     */
    public static String toJson(Object object){
        return getGson().toJson(object);
    }

    /**
     * json转换成对象
     * @param jsonString
     * @param type
     * @param <T>
     * @return
     */
    public static <T> T json2T(String jsonString, Type type) {
        return getGson().fromJson(jsonString, type);
    }
}
